#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) Huawei Technologies Co., Ltd. 2022. All rights reserved.
# Description: Main clean script for liblinux
# Author: Huawei OS Kernel Lab
# Create: Sun Aug 21 11:33:17 2022

set -e
# cleanup conflict envs
export SRCTREE=""
export MAKEFLAGS=""
export SRC=""
export MFLAGS=""
export KBUILD_SRC=""


export TOP=$(cd $(dirname $0); pwd)
export EXTLIB_OUTPUT=${EXTLIB_OUTPUT:-${TOP}/build}

# hack for run clean.sh directly
[ -z "$ARCH" ]			&& export ARCH=arm64
[ -z "$EXTLIB_SRC" ]		&& export EXTLIB_SRC=$pwd
[ -z "$MAKE" ]			&& export MAKE=make

# hack for aarch64 -> arm64
if [ "${ARCH}" = "aarch64" ]; then
	export ARCH="arm64"
fi

${MAKE} -C ${EXTLIB_SRC} O=${EXTLIB_OUTPUT} clean
